package util.sms;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;

/**
 * Created by MondaDev01 on 2017/11/6.
 */
public class Duanxin {

    public static void main(String[] args) throws Exception {

        HttpClient client = new HttpClient();
        PostMethod post = new PostMethod("http://gbk.api.smschinese.cn");
        post.addRequestHeader("Content-Type",  "application/x-www-form-urlencoded;charset=gbk"); //在头文件中设置转码
        NameValuePair[] data = { new NameValuePair("Uid", "mongda"),        //注册的用户名
                new NameValuePair("Key", "E88883A5A41BEFC9C3E68ABF060A"),              //接口密钥
                new NameValuePair("smsMob", "18312378045"),               // 发送手机号码
                new NameValuePair("smsText", "验证码：9999") };           //短信内容
        post.setRequestBody(data);

        client.executeMethod(post);
         post.getResponseHeaders();
         post.getStatusCode();

        String result = new String(post.getResponseBodyAsString().getBytes( "gbk"));
        System.out.println(result);
        post.releaseConnection();



    }



}
